package com.xxxx.dao;

import com.xxxx.pojo.Employee;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * Created By ShaoXikai on 2022/7/16
 */
@Repository
public class EmpDao {
    public static Map<Integer, Employee> employeeMap = new HashMap<>();
    private static Integer initId = 16;

    static {
        employeeMap.put(11, new Employee(1, "张三", "151313131@163.com", "男"));
        employeeMap.put(12, new Employee(2, "李四", "111111111@163.com", "女"));
        employeeMap.put(13, new Employee(3, "王五", "sjjsjjs@163.com", "男"));
        employeeMap.put(14, new Employee(1, "44", "444444444444@163.com", "男"));
        employeeMap.put(15, new Employee(2, "55", "555555555@163.com", "女"));
        employeeMap.put(16, new Employee(3, "66", "666666666666666@163.com", "男"));
    }

    public Collection<Employee> empList() {
        return employeeMap.values();
    }

    public void addEmp(Employee employee) {
        if (employee.getId() == null) {
            employee.setId(initId++);
        }
        employeeMap.put(initId, employee);
    }

    // public String delEmp(int id) {
    //     employeeMap.remove(id);
    //     return "1";
    // }
    public Employee getById(Integer id) {
        return employeeMap.get(id);
    }

}
